home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glider 3.14 / source / Glider parts ƒ / H-HandleTheMenus.p < prev    next >
Encoding:
Text File  |  1993-06-03  |  5.3 KB  |  179 lines  |  [TEXT/PJMM]

  1. unit HandleTheMenus;
  2.  
  3. interface
  4.  
  5.     uses
  6.         AboutIt, Dialogs, Sound, GameUtilities, GliderMain, InitializeAll;
  7.  
  8.     procedure DoBegintheGame;
  9.     procedure Handle_My_Menu (var doneFlag, Pausing, Playing, gliderCraft, soundOn: boolean; var leftControl, rightControl: char; theMenu, theItem: integer; var theInput: TEHandle);
  10.  
  11. implementation
  12.  
  13. {==============================================}
  14.  
  15.     procedure DoBegintheGame;
  16.     begin
  17.         FlushEvents(EveryEvent, 0);    {Toss out all events                                }
  18.         Playing := TRUE;                    {Set the bools.                                    }
  19.         pausing := FALSE;
  20.         switchUntouched := TRUE;
  21.         darkOn := FALSE;
  22.         highScoresOut := FALSE;
  23.         gliderNumber := numberBegin;
  24.         levelOn := levelBegin;
  25.         theScore := 0;
  26.         gameTime := 0;
  27.         totalTime := 0;
  28.         DoFast;
  29.         DisableItem(GetMenu(L_Game), 1);    {Turn off the Begin menu item.            }
  30.         DisableItem(GetMenu(L_Game), 2);    {Turn off Begin in Room... menu item.    }
  31.         EnableItem(GetMenu(L_Game), 4);    {Turn on Pause menu item.                }
  32.         EnableItem(GetMenu(L_Game), 5);    {Turn on End a Game menu item.            }
  33.         DisableItem(GetMenu(L_Options), 0);    {Turn off the entire Apple menu.    }
  34.         ResetGliderPos;                            {Get glider in upper left hand corner}
  35.         FoldTheGlider;
  36.         GetSet;                                    {And get set!!!                        }
  37.     end;
  38.  
  39. {==============================================}
  40.  
  41.     procedure Handle_My_Menu;
  42.         var
  43.             DNA, index: integer;    {For opening DAs                            }
  44.             BoolHolder: boolean;    {For SystemEdit result                        }
  45.             DAName: Str255;        {For getting DA name                        }
  46.             SavePort: GrafPtr;    {Save current port when opening DAs    }
  47.             tempRect: Rect;        {For warning in Sound_On                    }
  48.  
  49.     begin
  50.         case theMenu of        {Do selected menu list                        }
  51.             L_Apple: 
  52.                 begin
  53.                     case theItem of    {Handle all commands in this menu list    }
  54.                         C_About_Glider_2_0: 
  55.                             begin
  56.                                 DisableItem(GetMenu(L_Apple), 0);            {Turn off all the menus                }
  57.                                 DisableItem(GetMenu(L_Game), 0);
  58.                                 DisableItem(GetMenu(L_Options), 0);
  59.                                 DrawMenuBar;
  60.                                 Open_AboutIt;
  61.                             end;
  62.                         otherwise                                        {Handle the DAs                        }
  63.                             begin
  64.                                 GetPort(SavePort);                            {Save the current port                }
  65.                                 GetItem(AppleMenu, theItem, DAName);    {Get the name of the DA selected    }
  66.                                 DNA := OpenDeskAcc(DAName);                {Open the DA selected                }
  67.                                 SetPort(SavePort);                            {Restore to the saved port            }
  68.                             end;
  69.                     end;
  70.                 end;
  71.  
  72.             L_Game: 
  73.                 begin
  74.                     case theItem of                    {Handle all commands in the Game menu list    }
  75.                         C_Start_Game: 
  76.                             begin
  77.                                 DoBegintheGame;
  78.                             end;
  79.  
  80.                         C_Start_in_Room: 
  81.                             begin
  82.                                 D_BeginWhere(levelBegin);    {Call the dialog                }
  83.                                 levelOn := levelBegin;        {When back from dialog...    }
  84.                                 UpDate_GliderMain;            {update the main window        }
  85.                                 DoBegintheGame;                {and then begin the game.    }
  86.                             end;
  87.  
  88.                         C_Pause: 
  89.                             begin
  90.                                 Pausing := not Pausing;        {Toggle the bool variable.    }
  91.                                 if Pausing then                {We change the menu item    }
  92.                                     begin                        {to Continue while paused    }
  93.                                         SetItem(GetMenu(L_Game), theItem, 'Continue');
  94.                                         SetPort(mainWindow);
  95.                                         ShowCursor;                {Un-obscure the cursor        }
  96.                                     end
  97.                                 else
  98.                                     begin
  99.                                         ObscureCursor;            {Rehide the cursor.  And    }
  100.                                         SetItem(GetMenu(l_Game), theItem, 'Pause');
  101.                                     end;                            {put Pause back into menu.    }
  102.                             end;
  103.  
  104.                         C_End_Game: 
  105.                             begin
  106.                                 DoFinalScore;                    {Game is aborted, but program not Quit.    }
  107.                             end;
  108.  
  109.                         C_Quit: 
  110.                             begin
  111.                                 Playing := FALSE;
  112.                                 doneFlag := TRUE;
  113.                             end;
  114.                         otherwise
  115.                             begin
  116.                             end;
  117.                     end;                        {End of item case}
  118.                 end;                        {End for this list}
  119.  
  120.             L_Options: 
  121.                 begin
  122.                     case theItem of        {Handle all commands in the Option menu list}
  123.                         C_Glider: 
  124.                             begin
  125.                                 gliderCraft := TRUE;
  126.                                 CheckItem(GetMenu(L_Options), 1, TRUE);        {Put the checkmarks in     and out    }
  127.                                 CheckItem(GetMenu(L_Options), 2, FALSE);    {of the proper menu items.            }
  128.                                 thrust := gliderForwardFast;                    {Change glide ratio                    }
  129.                                 stall := gliderBackwardFast;
  130.                             end;
  131.                         C_Dart: 
  132.                             begin
  133.                                 gliderCraft := FALSE;
  134.                                 CheckItem(GetMenu(L_Options), 2, TRUE);
  135.                                 CheckItem(GetMenu(L_Options), 1, FALSE);
  136.                                 thrust := dartForwardFast;
  137.                                 stall := dartBackwardFast;
  138.                             end;
  139.                         C_Sound_On: 
  140.                             begin
  141.                                 soundOn := not soundOn;
  142.                                 CheckItem(GetMenu(L_Options), C_Sound_On, soundOn);    {If on, put a checkmark        }
  143.                             end;
  144.                         C_Number_of_Gliders: 
  145.                             begin
  146.                                 D_Number_of_Gliders(numberBegin);            {Call this dialog                }
  147.                             end;
  148.                         C_Controls: 
  149.                             begin
  150.                                 D_Controls(leftControl, rightControl);            {And call this dialog            }
  151.                                 scoresChanged := TRUE;
  152.                             end;
  153.                         C_Fast: 
  154.                             begin
  155.                                 gameSpeed := fastSpeed;
  156.                                 CheckItem(GetMenu(L_Options), C_Fast, TRUE);    {If on, put a checkmark        }
  157.                                 CheckItem(GetMenu(L_Options), C_Slow, FALSE);    {If on, put a checkmark        }
  158.                             end;
  159.                         C_Slow: 
  160.                             begin
  161.                                 gameSpeed := slowSpeed;
  162.                                 CheckItem(GetMenu(L_Options), C_Slow, TRUE);    {If on, put a checkmark        }
  163.                                 CheckItem(GetMenu(L_Options), C_Fast, FALSE);    {If on, put a checkmark        }
  164.                             end;
  165.                         otherwise
  166.                             begin
  167.                             end;
  168.                     end;
  169.                 end;                                                        {End for this list                }
  170.             otherwise
  171.                 begin
  172.                 end;
  173.         end;                                                            {End for lists                    }
  174.         HiliteMenu(0);                                                {Turn menu selection off    }
  175.     end;
  176.  
  177. {==============================================}
  178.  
  179. end.